<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>传习教育网上书城</title>
<link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/css/style.css" />
</head>
<body>
<div id="header" class="wrap">
	<div id="logo">传习教育网上书城</div>
	<div style="width:380px; height:50px; float:right; position:absolute; left:60%; top:2px; line-height:50px">
	    <img src="${pageContext.request.contextPath}/images/cart.gif" style="margin-bottom:-4px" width="26" height="23">
		         <c:if test="${!empty user}">
                                                      欢迎您： ${user.username} &nbsp;
                 </c:if> 
                 <c:if test="${empty user}">
                  <a href="${pageContext.request.contextPath}/login.jsp">登录</a>
				  <a href="${pageContext.request.contextPath}/register.jsp">注册</a> 
                 </c:if>
		</div>
	<div id="navbar">
		<div class="userMenu">
			<ul>
				<li class="current"><a href="${pageContext.request.contextPath}/book/user?method=logout">User首页</a></li>
				<li><a href="${pageContext.request.contextPath}/orderlist.jsp">我的订单</a></li>
				<li><a href="${pageContext.request.contextPath}/shopping.jsp">购物车</a></li>
				<li><a href="${pageContext.request.contextPath}/book/user?method=logout">注销</a></li>
			</ul>
		</div>
		<form method="post" name="search" action="${pageContext.request.contextPath}/book/product?method=search">
			搜索：<input class="input-text" type="text" name="keywords" />
			<input class="input-btn" type="submit" name="submit" value=""/>
		</form>
	</div>
</div>
<div id="content" class="wrap">
	<div class="list bookList">
	<form method="post" name="shoping" 
		  action="${pageContext.request.contextPath}/book/cart?method=addCart" onsubmit="return checkId()">
			<table>
				<tr class="title">
					<th class="checker"></th>
					<th>书名</th>
					<th class="price">价格</th>
					<th class="store">库存</th>
					<th class="view">图片预览</th>
				</tr>
				<tr>
				    <c:if test="${empty products}">
				     您查找的图书不存在
				</c:if>	
				</tr>			
				<c:forEach items="${products}" var="product">
				<tr>
					<td><input type="checkbox" name="bookId" value="${product.id}" /></td>
					<td class="title">${product.name}</td>
					<td>￥${product.price}</td>
					<td>${book.pnum}</td>
					<td class="thumb"><img src="${pageContext.request.contextPath}/${product.imgurl}" width="90" height="90" /></td>
				</tr>
				</c:forEach>
			</table>
			<div class="page-spliter">
				<!--  <a href="#">&lt;</a>
				<a href="#">首页</a>
				<span class="current">1</span>
				<a href="#">2</a>
				<a href="#">3</a>
				<a href="#">4</a>
				<span>...</span>
				<a href="#">尾页</a>
				<a href="#">&gt;</a>
				-->
				<%--  <a href="${pageContext.request.contextPath}/book/product?method=show&pageIndex=1">首页</a>&nbsp;
 				<a href="${pageContext.request.contextPath}/book/product?method=show&pageIndex=${bookList.currentIndex-1}">上一页</a>
 				<a href="${pageContext.request.contextPath}/book/product?method=show&pageIndex=${bookList.currentIndex+1}">下一页</a>
 				<a href="${pageContext.request.contextPath}/book/product?method=show&pageIndex=${bookList.totalpages}">末页</a> --%>
			</div>
			<div class="button">
			 <input class="input-btn" type="submit" name="submit" value="" />
			 </div>
		</form>
	</div>
</div>
<script type="text/javascript" src="js/jquery-3.3.1.js"></script>
<script type="text/javascript">
   function checkId(){
	   //检测有没有复选框被选中 \${} el表达式    \$() jquery
	   if($("input[type='checkbox']").is(':checked')){
		   return true;
	   }else{
		   alert("没有被选中的商品,请选一个。");
		   return false;
	   }
   }
</script>
<div id="footer" class="wrap">
	传习教育网上书城 &copy; 版权所有
</div>
</body>
</html>
